import Mock from 'mockjs'
import loginAPI from './login'
import lossAPI from './loss'
import companyInfoAPI from './companyInfo'
import publicInfoAPI from './publicInfos'
// 修复在使用 MockJS 情况下，设置 withCredentials = true，且未被拦截的跨域请求丢失 Cookies 的问题
// https://github.com/nuysoft/Mock/issues/300
Mock.XHR.prototype.proxy_send = Mock.XHR.prototype.send
Mock.XHR.prototype.send = function () {
  if (this.custom.xhr) {
    this.custom.xhr.withCredentials = this.withCredentials || false
  }
  this.proxy_send(...arguments)
}

// Mock.setup({
//   timeout: '350-600'
// })

// 登录相关
Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/login\/logout/, 'post', loginAPI.logout)
Mock.mock(/\/user\/info/, 'get', loginAPI.getUserInfo)
Mock.mock(/\/loss\/info/, 'get', lossAPI.lossInfo)

// 公共信息相关
Mock.mock(/\/pro\/info/, 'get', publicInfoAPI.financialProductInfo)
Mock.mock(/\/currencyRate\/info/, 'get', publicInfoAPI.foreignCurrencyRateInfo)
Mock.mock(/\/exchangeRate\/info/, 'get', publicInfoAPI.foreignExchangeRateInfo)
Mock.mock(/\/organizationName\/info/, 'get', publicInfoAPI.organizationNameInfo)
Mock.mock(/\/AccICheckingInfo\/info/, 'get', publicInfoAPI.numOrIBANAccICheckingInfo)
Mock.mock(/\/newOrOldAcc\/info/, 'get', publicInfoAPI.newOrOldAccICheckingInfo)
Mock.mock(/\/newOrOldCusICheckingInfo\/info/, 'get', publicInfoAPI.newOrOldCusICheckingInfo)

// 公司相关companyInfoAPI
Mock.mock(/\/user\/info/, 'get', companyInfoAPI.companyInfo)
// 文章相关
export default Mock
